package com.caird.pmp.iot.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;

import java.util.Date;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class DeviceShadow {

    /**
     * 每天登录打卡
     */
    public void clockIn() {
        Date date = new Date();

        int bytePos = date.getYear() * 12 + date.getMonth() - 120 * 12 - 9;
        int bitPos = 1 << (date.getDate() - 1);

        if (null == this.loginClockIn) {
            this.loginClockIn = new int[bytePos + 1];
        } else if (bytePos >= this.loginClockIn.length) {
            int newLoginClockIn[] = new int[bytePos + 1];
            System.arraycopy(this.loginClockIn, 0, newLoginClockIn, 0, this.loginClockIn.length);
            this.loginClockIn = newLoginClockIn;
        }

        this.loginClockIn[bytePos] |= bitPos;
    }


    /**注册时间*/
    private Date regTime;
    /**注册次数*/
    private Integer regCount;
    /**序列号*/
    private String sn;
    /**制造商*/
    private String maker;
    /**型号*/
    private String model;
    /**SIM卡号*/
    private String simNo;

    /**登录时间*/
    private Date loginTime;
    /**登录次数*/
    private Integer loginCount;
    /**登录打卡 2020年10月起始*/
    private int[] loginClockIn;

    /**日志时间*/
    private Date logTime;
    /**日志内容*/
    private String log;
    /**日志次数*/
    private Integer logCount;

    /**日志时间*/
    private Date atTime;
    /**日志内容*/
    private String at;
    /**日志次数*/
    private Integer atCount;

    /**登录状态*/
    private Boolean isOnline;
    /**在线时间*/
    private Date onlineTime;
    /**离线时间*/
    private Date offlineTime;

    /**更新时间*/
    private Date time;

}
